﻿using System;
using System.Linq;
using Data;
using Data.Model;
using ServiceModel.Operations;
using ServiceStack.ServiceInterface.ServiceModel;

namespace ServiceInterface
{
    public class AuthentificationService : ServiceStack.ServiceInterface.Service
    {
        public GetUsersResponse Any(GetUsers request)
        {
            var response = new GetUsersResponse();
            try
            {
                var uc = new UnitOfWork();
                var userProvider = new Repository<UserBase>(uc.Session);
                response.Users = userProvider.All().ToList();
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Message = ex.Message;
                response.ResponseStatus.StackTrace = ex.StackTrace;
            }
            return response;
        }
    }


    public static class Extensions
    {
        public static bool IsSuccess(this ResponseStatus status)
        {
            return string.IsNullOrWhiteSpace(status.Message);
        }
    }
}
